Skip to main content

Posts tagged with 'Couchbase Server'

My job as a developer evangelist for Couchbase means than I work much less with SQL Server than I used to. However, it doesn't mean I don't keep up with it.

In fact, inspired by Couchbase, I decided to try out using SQL Server as a sort of document data store. SQL Server 2016 introduced some interesting new features that make this kinda possible: JSON_VALUEJSON_QUERY, and JSON_MODIFY.

I set up a "document" table, which is two fields: a guid and an nvarchar(max). This is kinda like a Couchbase bucket: a key and a JSON document to go with it.

I put fairly complex hierarchical documents in these fields, something like:

I say "fairly complex", because representing this in a standard normalized fashion would require at least two tables, foreign keys, constraints, and then data migration and schema migration as the model evolves.

Now, suppose I want to execute a query and find all the document that are "Show=true". With Couchbase and N1QL, I would just use something like "SELECT * FROM `bucket` WHERE show = true".

With SQL Server, there's a little more work. "SELECT t.key, t.doc FROM [table] t WHERE JSON_VALUE(t.SpeakingInfo,'$.Show') = 'true'". Notice that JSON_VALUE is being applied to a text field, and a JSON path is used within JSON_VALUE to get a specific value from within that JSON object.

For this simple project I'm doing, that's all I need. No idea yet what kind of performance level I can expect from JSON_VALUE and more complex JSON paths.

But, this is definitely an example of the kinds of database convergence I've been telling people about. The separations between NoSQL and SQL are becoming less strict, at least in terms of data modeling and querying.

You need to be using SQL Server 2016 or SQL Server Azure to take advantage of the JSON_* functions.

(This is a cross-post of a blog that was originally posted to the Couchbase Blog - Upcoming #Couchbase Events in Austin, Houston and New York City)

I’m going to be in New York on October 8th and Texas from October 10th to October 13th. If you’re in either of those areas and interested in NoSQL and Couchbase, now is a good chance to attend some sessions, visit some great user groups, and ask me questions in-person.

Couchbase in Texas

Here’s where I will be in between meals of beef brisket (image by Arnold Gatilao, licensed through Creative Commons):

A great NYC conference! Four great Texas groups! I’m going to bring whatever stickers and swag that I can fit in my luggage with me, and I may even just bring the CouchCase along too.

I was recently on David Giard's show Technology and Friends! This is my second time on his show. This time I got to talk about NoSQL and Couchbase Server in particular. Check it out, and check out Couchbase Server.

 

Calvin Allen is a developer who is using Chocolatey NuGet to automate the setup of development environments and is also creating Chocolatey packages of his own.

Show notes:

Calvin Allen on Twitter

Want to be on the next episode? You can! All you need is the willingness to talk about something technical.

Theme music is "Crosscutting Concerns" by The Dirty Truckers, check out their music on Amazon or iTunes.

Matthew D. Groves

About the Author

Matthew D. Groves lives in Central Ohio. He works remotely, loves to code, and is a Microsoft MVP.

Latest Comments

Twitter